package com.hex.campus.backend.hex_campus_backend.controller;

import com.hex.campus.backend.hex_campus_backend.entity.PartnerMatch;
import com.hex.campus.backend.hex_campus_backend.repository.PartnerMatchRepository;
import com.hex.campus.backend.hex_campus_backend.util.JwtUtil;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/matches")
@RequiredArgsConstructor
public class MatchController {

    private final PartnerMatchRepository partnerMatchRepository;
    private final JwtUtil jwtUtil;

    @GetMapping
    public List<PartnerMatch> getMyMatches(@RequestHeader("Authorization") String token) {
        Long userId = jwtUtil.validateToken(token.replace("Bearer ", ""));
        return partnerMatchRepository.findByUserInvolved(userId);
    }
}


